package com.symria.server.dao.common;

import java.util.Date;

import org.springframework.jdbc.core.JdbcTemplate;

import com.symria.framework.dao.util.TemplateDao;
import com.symria.framework.page.Page;
import com.symria.server.po.IosActivate;
import com.symria.server.po.IosAdConfig;
import com.symria.server.po.IosChannelConfig;
import com.symria.server.po.IosClick;
import com.symria.system.statement.Statement;

public class IosDao extends TemplateDao {
	
	public void searchAdConfig(IosAdConfig config,Page page){
		Statement stms = stmsFactory.createStatement(" from IosAdConfig c where 1=1");
		if(config!=null){
			stms.append("and", "status", "=", config.getStatus());
			stms.appendLike(null, "and", "packName", config.getPackName());
			
		}
		stms.addOrderBy(" c.packId desc");
		templateDao.search(stms, page);
	}
	public void searchChannelConfig(IosChannelConfig config,Page page){
		Statement stms = stmsFactory.createStatement(" from IosChannelConfig c where 1=1 ");
		if(config!=null){
			stms.append("and", "status", "=", config.getStatus());
			stms.appendLike(null, "and", "channelName", config.getChannelName());
		}
		stms.addOrderBy("c.userId desc");
		templateDao.search(stms, page);
	}
	public void searchIosClick(Page page,IosClick click,Date beginDate ,Date endDate){
	    Statement stms = stmsFactory.createStatement(" from IosClick c where 1=1");
	              if(click!=null){
	            	  stms.append("and", "c.appId", "=", click.getAppId());
	            	  stms.append("and", "c.channel", "=", click.getChannel());
	            	  stms.append("and", "c.mac", "=", click.getMac());
	            	  stms.append("and", "c.idfa", "=", click.getIdfa());
	            	  stms.append("and", "c.status", "=", click.getStatus());
	            	  stms.appendBetween("and", "c.createTime", beginDate, endDate);
	              }
	              stms.addOrderBy(" c.id desc");
	    templateDao.search(stms, page);
	}
	public void searchIosActivate(Page page,IosActivate activate,Date beginDate,Date endDate){
	    Statement stms = stmsFactory.createStatement(" from IosActivate c where 1=1");
	              if(activate!=null){
	            	  stms.append("and", "c.appId", "=", activate.getAppId());
	            	  stms.append("and", "c.channel", "=", activate.getChannel());
	            	  stms.append("and", "c.mac", "=", activate.getMac());
	            	  stms.append("and", "c.idfa", "=", activate.getIdfa());
	            	  stms.append("and", "c.status", "=", activate.getStatus());
	            	  stms.appendBetween("and", "c.createTime", beginDate, endDate);
	              }
	    stms.addOrderBy(" c.id desc");
	    templateDao.search(stms, page);
	}
}
